package cn.com.code.hwjs;


import java.util.*;

/**
 * https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b?tpId=37&tqId=21278&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/5/3
 */
public class Hwjs55 {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int i = scanner.nextInt();
      System.out.println(countNum(i));
    }
  }

  private static int countNum(int number) {
    Set<Integer> set = new HashSet<>();
    for (int i = 1; i <= number; i++) {
      if (i % 7 == 0) {
        set.add(i);
      } else {
        String num = String.valueOf(i);
        if (num.contains("7")) {
          set.add(i);
        }
      }
    }
    return set.size();
  }

}
